/**
 * 公司用户列表
 *
 * @author liuxiaotang
 */
define(["app", "comm/pager/PagerControl", "js/services/MessageBox", "js/services/MuseService"], function (app) {

    var deps = ["$scope", "$state", "$modal", "MessageBox", "MuseService"];

    function controller ($scope, $state, $modal, MessageBox, MuseService) {
        //初始化查询对象 和 分页对象
        app.regsiterCacheData($scope, $state);
        $scope.queryObj = $scope.queryObj || {};
        $scope.pagerObj = {
            //当前页号
            currentPage: 1,
            // 每页显示条数
            pageSize: 15,
            //总记录数
            totalCount: -1
        };

        //获取列表
        $scope.getObjList = function () {
            //封装查询条件
            $scope.pagerObj.searchMap = $scope.queryObj;


            MuseService.post(baseServices_restfulUrl + "admin/adminLog/search.json", $scope.pagerObj).success(
                function (data, status, headers, config) {
                    if (data.state == 0) {
                        $scope.adminLogList = data.data.data;
                        //分页器
                        $scope.pagerObj = PageCtrl().page($scope.pagerObj, data.totalPage, $scope.pagerObj.currentPage);
                    } else {
                        MessageBox.notify(data.message);
                    }
                });
        };

        $scope.getObjList();

        //查看请求参数
        $scope.requestParam = function (requestParam) {
            if (!isEmpty(requestParam)) {
                MessageBox.confirm({
                    msg: '<pre>' + beautyJsonStr(requestParam, false) + '</pre>',
                    header: '请求参数'
                }, 'lg');
            } else {
                MessageBox.notify('参数为空')
            }
        };

        //查看返回参数
        $scope.responseParam = function (responseParam) {
            if (!isEmpty(responseParam)) {
                MessageBox.confirm({
                    msg: '<pre>' + beautyJsonStr(responseParam, false) + '</pre>',
                    header: '返回参数'
                }, 'lg');
            } else {
                MessageBox.notify('参数为空')
            }
        };

        //重置查询表单
        $scope.resetParam = function () {
            app.regsiterCacheData($scope, $state);
            $scope.queryObj = $scope.queryObj || {};
            $scope.getObjList();
        };


        $scope.pageChanged = function () {
            PageCtrl().check($scope.pagerObj);
            $scope.getObjList();
        }
    }

    controller.$inject = deps;
    app.lazy.controller("AdminLogListController", controller);
});
